package com.jinmdz.fmis.api.api.controller;

import com.jinmdz.fmis.api.api.model.common.IdData;
import com.jinmdz.fmis.api.api.model.common.IdVersionData;
import com.jinmdz.fmis.api.api.model.wake.*;
import com.jinmdz.fmis.api.api.service.WakeMournService;

import com.jinmdz.fmis.api.base.BaseController;
import com.jinmdz.fmis.core.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;


/**
 * 礼厅守灵任务信息相关接口
 *
 * @author LiCongLu
 * @date 2020-01-20 11:08
 */
@Api(description = "礼厅守灵任务信息相关接口")
@RestController()
@RequestMapping("/api/wake-mourn")
public class WakeMournController extends BaseController {

    @Resource
    private WakeMournService wakeMournService;

    /**
     * 根据mourn_ceremony表中id加载礼厅任务信息
     *
     * @param data
     * @return
     * @author LiCongLu
     * @date 2020-01-19 13:33
     */
    @ApiOperation(value = "根据mourn_ceremony表中id加载礼厅任务信息", notes = "根据ID加载礼厅信息")
    @PostMapping("/load-wake-mourn-with-id")
    public BaseResult<WakeMournData> loadWakeMournWithId(@RequestBody IdData data) {
        return resultHandler(data, userItem -> wakeMournService.loadWakeMournWithId(data));
    }

    /**
     * 保存礼厅信息到mourn_ceremony表中
     *
     * @param data 礼厅数据
     * @return
     * @author LiCongLu
     * @date 2020-01-20 11:13
     */
    @ApiOperation(value = "保存礼厅信息到mourn_ceremony表中", notes = "保存礼厅任务信息到mourn_ceremony表中")
    @PostMapping("/save-wake-mourn")
    public BaseResult<WakeMournData> saveWakeMourn(@RequestBody WakeMournData data) {
        return resultHandler(data, userItem -> wakeMournService.saveWakeMourn(userItem, data));
    }

    /**
     * 从mourn_ceremony表中删除指定id的礼厅任务信息记录
     *
     * @param data 主键和版本号
     * @return
     * @author LiCongLu
     * @date 2020-01-20 11:15
     */
    @ApiOperation(value = "从mourn_ceremony表中删除指定id的礼厅任务信息记录", notes = "从mourn_ceremony表中删除指定id的礼厅任务信息")
    @PostMapping("/delete-wake-mourn-with-id")
    public BaseResult deleteWakeMournWithId(@RequestBody IdVersionData data) {
        return resultHandler(data, userItem -> wakeMournService.deleteWakeMournWithId(userItem, data));
    }

    /**
     * 根据礼厅类型加载守灵礼厅信息
     *
     * @param data 类型
     * @return
     * @author LiCongLu
     * @date 2020-03-08 18:04
     */
    @ApiOperation(value = "根据礼厅类型加载守灵礼厅信息", notes = "根据礼厅类型及预约入厅时间加载相应类型的守灵礼厅信息")
    @PostMapping("/load-wake-hall-with-date")
    public BaseResult<ArrayList<WakeHallItem>> loadWakeHallWithDate(@RequestBody WakeHallDateData data) {
        return resultHandler(data, userItem -> wakeMournService.loadWakeHallWithDate(data));
    }


    /**
     * 礼厅任务，界面权限验证及基础数据加载
     *
     * @param data 加载全部数据
     * @return
     * @author LiCongLu
     * @date 2020-01-20 11:20
     */
    @ApiOperation(value = "礼厅任务，界面权限验证及基础数据加载", notes = "根据ID加载礼厅信息\n" +
            "根据dictTypeCodes【hall_business_type、hall_status】加载字典信息\n" +
            "根据serviceItemTypeCode【use_in_mourn_ceremony】加载物品服务信息")
    @PostMapping("/load-wake-mourn-all")
    public BaseResult<WakeMournAllLoadData> loadWakeMournAll(@RequestBody WakeMournAllData data) {
        return resultHandler(data, userItem -> wakeMournService.loadWakeMournAll(data));
    }
}
